package com.zhu.instructions.constants;
import com.zhu.instructions.base.Index16Instruction;
import com.zhu.rtda.Frame;

/**
 * sipush: 将一个 short 值（-32768~32767）带符号扩展为 int 并压入操作数栈
 *
 * 格式：sipush <short>
 * 示例：sipush 1000 → 将 1000 压入栈
 */
public class SIPUSH extends Index16Instruction {

    @Override
    public void execute(Frame frame) {
        // 从操作数中读取一个 short，自动扩展为 int
        short val = (short) this.index;
        frame.getOperandStack().pushInt(val);
    }

    @Override
    public String toString() {
        return "sipush " + (short) this.index;
    }

}
